package com.jxw.launcher.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import com.jxw.launcher.R;

/* loaded from: classes.dex */
public class BatteryView extends View {
    private int mPower;

    public BatteryView(Context context) {
        super(context);
        this.mPower = 100;
    }

    public BatteryView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mPower = 100;
    }

    @Override // android.view.View
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.x21) - 3;
        int dimensionPixelSize2 = getResources().getDimensionPixelSize(R.dimen.x12);
        Paint paint = new Paint();
        paint.setColor(-1);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        int i = dimensionPixelSize + 0;
        canvas.drawRect(new Rect(0, 0, i, dimensionPixelSize2 + 0), paint);
        float f = this.mPower / 100.0f;
        Paint paint2 = new Paint(paint);
        paint2.setStyle(Paint.Style.FILL);
        paint2.setColor(Color.parseColor("#FEC006"));
        if (f != 0.0f) {
            canvas.drawRect(new Rect(3, 3, ((int) ((dimensionPixelSize - 3) * f)) + 0, (3 + dimensionPixelSize2) - 6), paint2);
        }
        int i2 = (0 + (dimensionPixelSize2 / 2)) - 2;
        Rect rect = new Rect(i, i2, i + 3, i2 + 5);
        paint2.setColor(-1);
        canvas.drawRect(rect, paint2);
    }

    public void setPower(int i) {
        this.mPower = i;
        if (this.mPower < 0) {
            this.mPower = 0;
        }
        invalidate();
    }
}
